from conftest import login_token
from ApiBase import ApiBase
import pytest,requests,os


class Test_address():
    def test_address_01(self, login_token):
        """修改地址"""
        userId, sessionId = login_token
        # 请求地址
        url = 'http://10.59.9.18/small/user/verify/v1/changeReceiveAddress'
        # 请求头
        headers = {
            'userId': str(userId),
            'sessionId': str(sessionId)
        }
        # 请求体
        data = {
            "id": 4545,
            "realName": "张某某",  # 修改姓名
            "phone": "13811033966",  # 修改手机号
            "address": "上海 浦东新区 陆家嘴",  # 修改地址
            "zipCode": "200000"  # 修改邮编
        }
        # 发送post请求
        r = requests.put(url=url, data=data, headers=headers)
        r_json = r.json()
        # 断言
        assert r_json['message'] == '修改成功'
        # 断言
        assert r_json['status'] == '0000'
        # 打印响应数据
        print(r_json)

    def test_delete_02(self, login_token):
        """删除地址"""
        userId, sessionId = login_token
        # 请求地址
        url = 'http://10.59.9.18/small/user/verify/v1/deleteReceiveAddress'
        # 请求头
        headers = {
            'userId': str(userId),
            'sessionId': str(sessionId)
        }
        # 请求体
        param = {
            "id": 3602
        }
        # 发送post请求
        r = requests.delete(url=url, params=param, headers=headers)
        r_json = r.json()
        # 断言
        # assert r_json['message'] == '修改成功'
        # # 断言
        # assert r_json['status'] == '0000'
        # 打印响应数据
        print(r_json)
